home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / WIZARD.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  9KB  |  358 lines

  1. /*    SCCS Id: @(#)wizard.c    3.0    90/01/09
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. /* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
  6. /*           - heavily modified to give the wiz balls.  (genat!mike)   */
  7. /*           - dewimped and given some maledictions. -3. */
  8.  
  9. #include "hack.h"
  10.  
  11. #ifdef OVLB
  12.  
  13. #ifdef HARD
  14. /*    TODO:    Expand this list.    */
  15. static const int NEARDATA nasties[] = {
  16.     PM_COCKATRICE, PM_ETTIN, PM_STALKER, PM_MINOTAUR, PM_RED_DRAGON,
  17.     PM_GREEN_DRAGON, PM_OWLBEAR, PM_PURPLE_WORM, PM_ROCK_TROLL, PM_XAN,
  18.     PM_GREMLIN, PM_UMBER_HULK, PM_VAMPIRE_LORD, PM_XORN, PM_ZRUTY,
  19. #ifdef ARMY
  20.     PM_CAPTAIN,
  21. #endif
  22.     };
  23. #endif /* HARD */
  24.  
  25. static const unsigned NEARDATA wizapp[] = {
  26.     PM_HUMAN, PM_WATER_DEMON, PM_VAMPIRE,
  27.     PM_RED_DRAGON, PM_TROLL, PM_UMBER_HULK,
  28.     PM_XORN, PM_XAN, PM_COCKATRICE,
  29.     PM_FLOATING_EYE,
  30.     PM_GUARDIAN_NAGA,
  31.     PM_TRAPPER
  32. };
  33.  
  34. #endif /* OVLB */
  35. #ifdef OVL0
  36.  
  37. /* If he has found the Amulet, make the wizard appear after some time */
  38. void
  39. amulet(){
  40.     register struct monst *mtmp;
  41.  
  42.     if(!flags.made_amulet || !flags.no_of_wizards)
  43.         return;
  44.     /* find wizard, and wake him if necessary */
  45.     for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  46.         if(mtmp->iswiz && mtmp->msleep && !rn2(40))
  47.             if(u.uhave_amulet) {
  48.             mtmp->msleep = 0;
  49.             if(dist(mtmp->mx,mtmp->my) > 2)
  50.                 You(
  51.     "get the creepy feeling that somebody noticed your taking the Amulet."
  52.                 );
  53.             return;
  54.             }
  55. }
  56.  
  57. #endif /* OVL0 */
  58. #ifdef OVLB
  59.  
  60. int
  61. mon_has_amulet(mtmp)
  62. register struct monst *mtmp;
  63. {
  64.     register struct obj *otmp;
  65.  
  66.     for(otmp = mtmp->minvent; otmp; otmp = otmp->nobj){
  67.         if(otmp->otyp == AMULET_OF_YENDOR && otmp->spe >= 0) return(1);
  68.     }
  69.     return(0);
  70. }
  71.  
  72. /* the wiz's prime directive */
  73. int
  74. wiz_get_amulet(mtmp)
  75. register struct monst *mtmp;
  76. {
  77.     /* if he doesn't have the amulet */
  78.     if(!mon_has_amulet(mtmp))
  79.         if(u.uhave_amulet) {
  80.  
  81.         /* player has it, dog them til he gets it or dies */
  82.         mnexto(mtmp);
  83.         } else {
  84.         register struct obj *otmp;
  85.  
  86.         /* if it is lying around someplace, he teleports to it */
  87.         for(otmp = fobj; otmp; otmp = otmp->nobj)
  88.             if(otmp->otyp == AMULET_OF_YENDOR && !otmp->spe) {
  89.             if(u.ux == otmp->ox && u.uy == otmp->oy) {
  90.                 /* player is standing on it */
  91.                 mnexto(mtmp);
  92.                 return(0);
  93.             }
  94.             if(!MON_AT(otmp->ox, otmp->oy) ||
  95.                 (mtmp->mx == otmp->ox && mtmp->my == otmp->oy)) {
  96.  
  97.                 /* teleport to it and pick it up */
  98.                 remove_monster(mtmp->mx, mtmp->my);
  99.                 place_monster(mtmp, otmp->ox, otmp->oy);
  100.                 if (cansee(mtmp->mx, mtmp->my))
  101.                 pline("%s picks up %s.", Monnam(mtmp),
  102.                                 xname(otmp));
  103.                 freeobj(otmp);
  104.                 mpickobj(mtmp, otmp);
  105.                 pmon(mtmp);
  106.                 return(1);
  107.             }
  108.             break;
  109.             }
  110.         /* we don't know where it is */
  111.         }
  112.  
  113.     /* he has it or can't find it */
  114.     /* secondary goal - stayin' alive */
  115.  
  116.     /* if wounded, hole up on or near the stairs (to block them) */
  117.     /* unless, of course, there are no stairs (e.g. endlevel */
  118.     if(mtmp->mhp < 20 + rnd(10) && (xupstair || yupstair))
  119.         if (mtmp->mx != xupstair && mtmp->my != yupstair)
  120.         mnearto(mtmp,xupstair,yupstair,TRUE);
  121.  
  122.     /* if you're not around, cast healing spells */
  123.     if(dist(mtmp->mx,mtmp->my) > (BOLT_LIM * BOLT_LIM))
  124.         if(mtmp->mhp <= mtmp->mhpmax - 8) {
  125.         mtmp->mhp += rnd(8);
  126.         return(1);
  127.         }
  128.         /* healthy wiz with nothing to do */
  129.         else if(!rn2(5))
  130.         mnexto(mtmp);
  131.  
  132.     /* the effect is that below 30 hp, wily wiz teleports
  133.        again and again, unless/until he blocks the stairs.
  134.  
  135.        if you keep away from the wounded wiz, he sits
  136.        there healing himself, until he gets healthy
  137.        and decides to punish you some more.  -3. */
  138.  
  139.     return(0);
  140. }
  141.  
  142. void
  143. aggravate()
  144. {
  145.     register struct monst *mtmp;
  146.  
  147.     for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
  148.         mtmp->msleep = 0;
  149.         if(!mtmp->mcanmove && !rn2(5)) {
  150.             mtmp->mfrozen = 0;
  151.             mtmp->mcanmove = 1;
  152.         }
  153.     }
  154. }
  155.  
  156. void
  157. clonewiz()
  158. {
  159.     register struct monst *mtmp2;
  160.  
  161.     if(mtmp2 = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy)) {
  162.         mtmp2->msleep = mtmp2->mtame = mtmp2->mpeaceful = 0;
  163.         if (!u.uhave_amulet && rn2(2)) {  /* give clone a fake */
  164.             mtmp2->minvent = mksobj(AMULET_OF_YENDOR,FALSE);
  165.             mtmp2->minvent->spe = -1;
  166.         }
  167.         unpmon(mtmp2);
  168.         mtmp2->m_ap_type = M_AP_MONSTER;
  169.         mtmp2->mappearance = wizapp[rn2(SIZE(wizapp))];
  170.         pmon(mtmp2);
  171.     }
  172. }
  173.  
  174. #ifdef HARD
  175. void
  176. nasty() {
  177.     register struct monst    *mtmp;
  178.     register int    i, tmp;
  179.  
  180.     if(!rn2(10) && Inhell) dsummon(&mons[PM_WIZARD_OF_YENDOR]);
  181.     else {
  182.         tmp = (u.ulevel > 3) ? u.ulevel/3 : 1; /* just in case -- rph */
  183.  
  184.         for(i = rnd(tmp); i > 0; --i)
  185.         if((mtmp = makemon(&mons[nasties[rn2(SIZE(nasties))]], u.ux, u.uy))) {
  186.  
  187.             mtmp->msleep = mtmp->mpeaceful = mtmp->mtame = 0;
  188.         } else
  189.           (void)makemon((struct permonst *)0, u.ux, u.uy); /* GENOD? */
  190.     }
  191.     return;
  192. }
  193.  
  194. /*    Let's resurrect the wizard, for some unexpected fun.    */
  195. void
  196. resurrect()
  197. {
  198.     register struct monst    *mtmp;
  199.  
  200.     if(mtmp = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy)) {
  201.         mtmp->msleep = mtmp->mtame = mtmp->mpeaceful = 0;
  202.         pline("A voice booms out...");
  203.         pline("\"So thou thought thou couldst kill me, fool.\"");
  204.     }
  205.  
  206. }
  207.  
  208. /*    Here, we make trouble for the poor shmuck who actually    */
  209. /*    managed to do in the Wizard.                */
  210. void
  211. intervene() {
  212.  
  213.     switch(rn2(6)) {
  214.  
  215.         case 0:
  216.         case 1:    You("feel vaguely nervous.");
  217.             break;
  218.         case 2:    if (!Blind)
  219.                 You("notice a %s glow surrounding you.",
  220.                   Hallucination ? hcolor() : black);
  221.             rndcurse();
  222.             break;
  223.         case 3:    aggravate();
  224.             break;
  225.         case 4:    nasty();
  226.             break;
  227.         case 5:    if (!flags.no_of_wizards) resurrect();
  228.             break;
  229.     }
  230. }
  231.  
  232. void
  233. wizdead(mtmp)
  234. register struct monst    *mtmp;
  235. {
  236.     flags.no_of_wizards--;
  237.     if(! u.udemigod)  {
  238.  
  239.         u.udemigod = TRUE;
  240.         u.udg_cnt = rn1(250, 50);
  241.  
  242.     /*  Make the wizard meaner the next time he appears  */
  243.         mtmp->data->mlevel++;
  244.         mtmp->data->ac--;
  245.     } else  
  246.         mtmp->data->mlevel++;
  247. }
  248. #endif /* HARD /**/
  249.  
  250. const char *random_insult[] = {
  251.     "antic",
  252.     "blackguard",
  253.     "caitiff",
  254.     "chucklehead",
  255.     "coistrel",
  256.     "craven",
  257.     "cretin",
  258.     "cur",
  259.     "dastard",
  260.     "demon fodder",
  261.     "dimwit",
  262.     "dolt",
  263.     "fool",
  264.     "footpad",
  265.     "imbecile",
  266.     "knave",
  267.     "maledict",
  268.     "miscreant",
  269.     "niddering",
  270.     "poltroon",
  271.     "rattlepate",
  272.     "reprobate",
  273.     "scapegrace",
  274.     "varlet",
  275.     "villein",    /* (sic.) */
  276.     "wittol",
  277.     "worm",
  278.     "wretch",
  279. };
  280.  
  281. const char *random_malediction[] = {
  282.     "Hell shall soon claim thy remains,",
  283.     "I chortle at thee, thou pathetic",
  284.     "Prepare to die, thou ",
  285.     "Resistance is useless,",
  286.     "Surrender or die, thou",
  287.     "There shall be no mercy, thou",
  288.     "Thou shalt repent of thy cunning,",
  289.     "Thou art as a flea to me,",
  290.     "Thou art doomed,",
  291.     "Thy fate is sealed,",
  292.     "Verily, thou shalt be one dead"
  293. };
  294.  
  295. #ifdef SOUNDS
  296. const char *demonic_malediction[] = {
  297.     "I first mistook thee for a statue, when I regarded thy head of stone.",
  298.     "Come here often?",
  299.     "Dost pain excite thee?  Wouldst thou prefer the whip?",
  300.     "Thinkest thou it shall tickle as I rip out thy lungs?",
  301.     "Eat slime and die!",
  302.     "Go ahead, fetch thy mama!  I shall wait.",
  303.     "Go play leapfrog with a herd of unicorns!",
  304.     "Hast thou been drinking, or art thou always so clumsy?",
  305.     "This time I shall let thee off with a spanking, but let it not happen again.",
  306.     "I've met smarter (and prettier) acid blobs.",
  307.     "Look!  Thy bootlace is undone!",
  308.     "Mercy!  Dost thou wish me to die of laughter?",
  309.     "Run away!  Live to flee another day!",    
  310.     "Thou hadst best fight better than thou canst dress!",
  311.     "Twixt thy cousin and thee, Medusa is the prettier.",
  312.     "Methinks thou wert unnaturally interested in yon corpse back there, eh, varlet?",
  313.     "Up thy nose with a rubber hose!",
  314.     "Verily, thy corpse could not smell worse!",
  315.     "Wait!  I shall polymorph into a grid bug to give thee a fighting chance!",
  316.     "Why search for the Amulet?  Thou wouldst but lose it, cretin.",
  317. };
  318. #endif
  319.  
  320. /* Insult or intimidate the player */
  321. void
  322. cuss(mtmp)
  323. register struct monst    *mtmp;
  324. {
  325. #ifdef SOUNDS
  326.     if (mtmp->iswiz) {
  327. #endif
  328.         if (!rn2(5))  /* typical bad guy action */
  329.         pline("%s laughs fiendishly.", Monnam(mtmp));
  330.         else 
  331.         if (u.uhave_amulet && !rn2(SIZE(random_insult)))
  332.             pline("\"Relinquish the amulet, %s!\"",
  333.               random_insult[rn2(SIZE(random_insult))]);
  334.         else if (u.uhp < 5 && !rn2(2))    /* Panic */
  335.             pline(rn2(2) ?
  336.               "\"Even now thy life force ebbs, %s!\"" :
  337.               "\"Savor thy breath, %s, it be thine last!\"",
  338.               random_insult[rn2(SIZE(random_insult))]);
  339.         else if (mtmp->mhp < 5 && !rn2(2))    /* Parthian shot */
  340.             verbalize(rn2(2) ?
  341.                   "I shall return." :
  342.                   "I'll be back.");
  343.         else
  344.             pline("\"%s %s!\"",
  345.               random_malediction[rn2(SIZE(random_malediction))],
  346.               random_insult[rn2(SIZE(random_insult))]);
  347. #ifdef SOUNDS
  348.     } else {
  349.         if (!rn2(5))
  350.         kludge("%s casts aspersions on your ancestry.", Monnam(mtmp));
  351.         else
  352.         verbalize(demonic_malediction[rn2(SIZE(demonic_malediction))]);
  353.     }
  354. #endif
  355. }
  356.  
  357. #endif /* OVLB */
  358.